package com.etoak.controller;

import com.etoak.bean.User;
import com.etoak.mapper.UserMapper;
import com.etoak.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: activemq-SpringMVC
 * @description:
 * @author: 管浩杰
 * @create: 2021-03-17 10:01
 **/


@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService service;

    /* 跳转到注册页面 */
    @RequestMapping("/toReg")
    public String toReg(){
        return "reg";
    }

    @PostMapping("/reg")
    public String register(User user){
        service.addUser(user);
        return "redirect:/user/toReg";
    }
}
